package com.my.buffers;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @description:
 * @author: marshal
 * @date: 2021-08-24 3:33 PM
 */
public class BufferedInputStreamTest {
    public static void main(String[] args) {
        try (
                var fis = new FileInputStream("file/bis.txt");
                var bis = new BufferedInputStream(fis);
        ) {
            // 一次读取18字节
            byte[] buff = new byte[18];
            // he total number of bytes read into the buffer
            var hasRead = 0;
            while ((hasRead = bis.read(buff)) != -1) {
                System.out.println(new String(buff, 0, hasRead));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
